package com.ai.nsa.utils;

/**
 * @author Feng Chen 2017/6/12.
 */
public class LeftPad {

    private LeftPad() {

    }

    public static String pad(int num, int length, String pad) {
        String format = "%" + length + "s";
        return String.format(format, num).replaceAll(" ", pad);
    }

    public static String pad(String str, int length, String pad) {
        if (str == null || str.length() == 0) {
            str = "";
        }
        String format = "%" + length + "s";
        return String.format(format, str).replaceAll(" ", pad);
    }

}
